<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/14
 * Time: 1:39
 */

namespace ServerApp\lib\server\conf;

use ServerApp\lib\config\LogConfig;
use ServerApp\lib\memory\Chan;
use ServerApp\lib\process\SProcess;
use ServerApp\lib\server\delay_push\DelayPush;
use ServerApp\lib\server\delay_push\IDelayPush;
use ServerApp\lib\server\model\swoole\ClientList;
use ServerApp\lib\server\model\swoole\FdList;
use ServerApp\lib\util\ServerHelper;

class CreateConf
{
    private static $instance = null;

    private function __construct(IConf $func1, IDelayPush $func2)
    {
        ServerHelper::init();
        LogConfig::init();
        Chan::getInstance();
        ClientList::getInstance();
        FdList::getInstance();
        tracker(I, "DDDDDDDDDDDDd");
        (new SProcess(function() use($func2){
            DelayPush::init($func2);
        }))->start();
        (new SProcess(function() use ($func1){
            (new Conf($func1))->run();
        }))->start();
    }

    public static function getInstance(IConf $func1, IDelayPush $func2)
    {
        if (self::$instance === null) {
            self::$instance = new self($func1, $func2);
        }
        return self::$instance;
    }
}